package com.example.mapp;

import com.example.entity.authority.PartyContract;
import com.example.mapp.buildSql.PartyContractMappSql;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by youkun on 2018/3/18.
 * 机构合同
 */
@Mapper
public interface PartyContractMapp {

    @Insert("insert into party_contract (" +
            "first_Party,second_Party,contract_Number,contract_Type,contract_Address,star_Time,end_Time,party_Id,remarks"+
            ",one_Price,contract_Name,add_user_id,file_list) values (" +
            "#{firstParty},#{secondParty},#{contractNumber},#{contractType},#{contractAddress},#{starTime},#{endTime},#{partyId},#{remarks}"+
            ",#{onePrice},#{contractName},#{addUserId},#{fileList})")
    @SelectKey(statement="select last_insert_id()",keyProperty = "id",keyColumn = "id",before = false,resultType = Long.class)
    int insert(PartyContract partyContract) throws Exception;

    @SelectProvider(type = PartyContractMappSql.class,method = "queryByPartyIdList")
    List<PartyContract> queryByPartyIdList(PartyContract partyContract)throws Exception;

    @Select(" select * from party_contract where party_id = #{partyId}")
    List<PartyContract> queryByPartyId(String partyId) throws Exception;

    @Delete(" delete from party_contract where id =#{id}")
    int deleteById(String id)throws Exception;

    @Select(" select * from party_contract where id = #{id}")
    PartyContract queryById(String id);

    @Update(" update party_contract set second_party=#{secondParty},contract_type=#{contractType},one_price=#{onePrice},contract_name=#{contractName},contract_number=#{contractNumber},contract_address=#{contractAddress},star_time=#{starTime},end_time=#{endTime},file_list=#{fileList} where id=#{id} ")
    void updateContract(PartyContract partyContract);
}
